package com.kevin.dao;

import java.sql.SQLException;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.kevin.userInfo.UserInfo;

public class IUserDaoImpl implements IUserDao {

	private HibernateTemplate hibernateTemplate;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	@Override
	public void saveUser(UserInfo user) throws SQLException {
		hibernateTemplate.save(user);
	}

	@Override
	public void delUser(UserInfo user) throws SQLException {
		hibernateTemplate.delete(user);
	}

	@Override
	public void editUsre(UserInfo user) throws SQLException {
		hibernateTemplate.update(user);
	}

	@Override
	public UserInfo getUserById(int id) throws SQLException {
		UserInfo user = (UserInfo) hibernateTemplate.get(UserInfo.class, id);
		return user;
	}

}
